/**
 * author:Administrator
 * date:2016/3/19
 * desc:TODO
 */
'use strict';

let BaseDomainEvent = require('../../lib/BaseDomainEvent.js');

let EVENT_TYPE = {
  /**********************************************/
  /**             order create 流程             */
  /**********************************************/
  orderPlaced: 'orderPlaced',         // 订单创建未确认
  wareReserved: 'wareReserved',       // 商品预订
  wareLacking: 'wareLacking',         // 商品数量不足
  orderCreated: 'orderCreated',       // 订单创建
  orderRecall: 'orderRecall',        // order 撤销
  /**********************************************/
  /**             order create 流程             */
  /**********************************************/

  orderPaid: 'orderPaid',             // 订单已支付
  //orderCancelled: 'orderCancelled', // 订单取消
  //orderPaid: 'orderPaid',

  // coupon
  couponApplied: 'couponApplied',
  couponLacking: 'couponLacking',
  couponReserved: 'couponReserved',
  couponLogUsed: 'couponLogUsed',
  attchCouponFail: 'attchCouponFail',

};

/**********************************************/
/**             order create 流程             */
/**********************************************/
class OrderPlaced extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.orderPlaced, order);
  }
}

class WareReserved extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.wareReserved, order);
  }
}

class WareLacking extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.wareLacking, order);
  }
}

class OrderCreated extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.orderCreated, order);
  }
}

class OrderRecall extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.orderCreated, order);
  }
}
/**********************************************/
/**             order create 流程             */
/**********************************************/

class CouponApplied extends BaseDomainEvent {
  constructor(sagaId, couponLog) {
    super(sagaId, EVENT_TYPE.couponApplied, couponLog);
  }
}

class CouponReserved extends BaseDomainEvent {
  constructor(sagaId, couponLog) {
    super(sagaId, EVENT_TYPE.couponReserved, couponLog);
  }
}

class CouponLogUsed extends BaseDomainEvent {
  constructor(sagaId, couponLog) {
    super(sagaId, EVENT_TYPE.couponLogUsed, couponLog);
  }
}

class OrderPaid extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.orderPaid, order);
  }
}

class CouponLacking extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.couponLacking, order);
  }
}

class AttchCouponFail extends BaseDomainEvent {
  constructor(sagaId, order) {
    super(sagaId, EVENT_TYPE.attchCouponFail, order);
  }
}

let events = {
  ENUM_EVENT: EVENT_TYPE,

  // order create 流程事件
  OrderPlaced: OrderPlaced,
  WareReserved: WareReserved,
  WareLacking: WareLacking,
  OrderCreated: OrderCreated,
  OrderRecall: OrderRecall,
  // order create 流程事件


  CouponApplied: CouponApplied,
  CouponReserved: CouponReserved,
  CouponLogUsed: CouponLogUsed,
  OrderPaid: OrderPaid,
  CouponLacking: CouponLacking,
  AttchCouponFail: AttchCouponFail,
};

module.exports = events;


